package com.dream.technology.components.FlowService.imp;

import com.alibaba.fastjson.JSONObject;
import com.dream.technology.components.FlowService.FlowDealService;
import com.dream.technology.components.FlowService.FlowProcessService;
//import com.dream.technology.config.MessageConfig;
//import com.dream.technology.vo.MsgMessage;
//import com.dream.technology.zycashLog.Console;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.UUID;

/**
 * 描述：风控入口
 *
 * @author chen_q_i@163.com
 * 2019/1/11 : 18:30.
 * @version : 1.0
 */
@Service("flowDealService")
public class FlowDealServiceImpl implements FlowDealService {


    @Autowired
    private AmqpTemplate template;

    @Autowired
    private FlowProcessService flowProcessService;

//    @Autowired
//    private  MessageConfig messageConfig;

//    @RabbitListener(queues = RiskMessageConfig.BORROWING_FORM_QUEUE)
//    public void dealBorrowingForm(OrderBorrowingForm form) throws Exception {
//
//        flowProcessService.startRun(form);
//
//
//    }


    /**
     * 发送结果
     *
     * @param json
     */
    @Override
    public void sendResult(String json) {

        //Console.info("send_result_mq_message--------",json);
       /* MsgMessage msgMessage = getMsgMessage(messageConfig.getServiceId(), MessageConfig.RISK_RESULT_VIRTUAL_CHANNEL);
        msgMessage.setBody(json);
        msgMessage.setOrderId(msgMessage.getOrderId());
        template.convertAndSend(MessageConfig.QUEUE_NAME, JSONObject.toJSONString(msgMessage));*/
//        template.convertAndSend(MessageConfig.QUEUE_NAME, json);
    }

   /* public MsgMessage getMsgMessage(String serviceId, String virtualChannel){
        MsgMessage msgMessage=new MsgMessage();
        Date now = new Date();
        msgMessage.setUpdateDate(now);
        msgMessage.setCreateDate(now);
        String host = null;
        try{
            host= InetAddress.getLocalHost().getHostAddress();
        }catch (UnknownHostException e){
            //Console.error("get server host Exception e:", e);
        }
        msgMessage.setServiceId(serviceId);
        msgMessage.setVirtualChannelCode(virtualChannel);
        msgMessage.setServiceIp(host);
        msgMessage.setOrderId(UUID.randomUUID().toString().replaceAll("-", ""));
        return msgMessage;
    }*/


}
